package workers

import (
	"black_mamba/global"
	"black_mamba/utils"
	"bytes"
	"encoding/base64"
	"fmt"
	"gitee.com/wengo/go-amazon"
	"gitee.com/wengo/go-mamba"
	api2captcha "github.com/2captcha/2captcha-go"
	http "github.com/Danny-Dasilva/fhttp"
	"github.com/PuerkitoBio/goquery"
	"image/gif"
	"io/ioutil"
	"strconv"
	"strings"
	"time"
)

type RegisterUser struct {
	UserName string
	Email    string
	Password string
	Cookie   string
}

type PhoneDetail struct {
	ID          int
	CountryCode string
	PhoneNumber string
}

type RegisterWorker struct {
	Worker
}

func NewRegisterWorker() *RegisterWorker {
	return &RegisterWorker{
		Worker{
			Topic: "register",
		},
	}
}

func (d *RegisterWorker) Execute(data map[string]interface{}) (ret interface{}) {
	/*
		   流程
		    1.访问首页
			2.新建收货地址，新建信用卡
			3.打开Listing
			4.加入购物车
			5.结账
			6.选择地址
			7.选择信用卡
			8.建立订单
	*/

	//defer func() {
	//	//可以打印错误信息
	//	//recover()
	//	//fmt.Println(recover())
	//
	//	//没有错就不要打印
	//	if err := recover(); err != nil { //产生了panic异常
	//		stackStr := string(debug.Stack())
	//		utils.WriteFile("error.log", fmt.Sprintf("%s\n%s\n", err, stackStr))
	//	}
	//}()

	var resp *mamba.Response
	var document *goquery.Document
	var err error

	//website := `na.account.amazon.com`
	website := `www.amazon.com`
	amz := amazon.NewAmazon(amazon.Settings{
		//JA3:       "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0",
		//UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
		//JA3: "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-51-43-13-45-28,,",
		//UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0",
		JA3:       "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
		UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
		BaseUri:   fmt.Sprintf("https://%s", website),
		//BaseUri:     "https://www.amazon.com",
		Header:      nil,
		Cookies:     nil,
		Debug:       true,
		DebugLength: 0,
		Proxy:       fmt.Sprintf("http://%s:%s@tunnel5.qg.net:14295", global.BM_CONFIG.Section("proxy").Key("username").Value(), global.BM_CONFIG.Section("proxy").Key("password").Value()),
		//Proxy:       `http://192.168.2.5:8080`,
		//Proxy: `http://FE6FC783:E0C53AF2F7CD@183.164.247.14:38091`,
		//Proxy: `http://lum-customer-c_17e58ad2-zone-residential:Jjyylu102697@zproxy.lum-superproxy.io:22225`,
		//Proxy: `http://lum-customer-c_17e58ad2-zone-residential-country-ad:Jjyylu102697@zproxy.lum-superproxy.io:22225`,
		//Proxy: `http://lum-customer-c_17e58ad2-zone-residential:Jjyylu102697@47.90.188.193:24001`,
		//Proxy: fmt.Sprintf("http://%s:%s@tunnel5.qg.net:14295", global.BM_CONFIG.Section("proxy").Key("username").Value(), global.BM_CONFIG.Section("proxy").Key("password").Value()),
		//Proxy: fmt.Sprintf("http://%s:%s@http-dynamic.xiaoxiangdaili.com:10030", global.BM_CONFIG.Section("proxy").Key("username").Value(), global.BM_CONFIG.Section("proxy").Key("password").Value()),
	})

	//isExecute := data["isExecute"].(*bool)
	var responsePath, responseUrl string

	registerUser := data["registerUser"].(*utils.RegisterAccount)

	d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": fmt.Sprintf("邮箱地址 -> %s", registerUser.Email)})
	d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": fmt.Sprintf("用户密码 -> %s", registerUser.Password)})

	continueExecute := true

	//var phoneTaskId int
	var phoneDetail = PhoneDetail{}
	for continueExecute {
		//if !*isExecute { //是否继续执行
		//	return
		//}

		switch {
		case resp == nil: // 首页
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "打开首页"})
			resp, document, err = amz.Navigate("/")
			if err != nil {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
				continueExecute = false
			}
		case responsePath == "/" && !strings.Contains(responseUrl, "new_account"):
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "提取注册链接"})
			registerUrl, err := amz.ExtractRegisterUrl(document)
			if err != nil {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
				continueExecute = false
			}

			resp, document, err = amz.Navigate(registerUrl)
		case responsePath == "/" && strings.Contains(responseUrl, "new_account"):
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "进入我的账户"})
			resp, document, err = amz.Navigate(`/gp/css/homepage.html`)
			if err != nil {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
				continueExecute = false
			}
		case responsePath == "/gp/css/homepage.html":
			link, exists := amz.ExtractSecurityUrl(document)
			if !exists {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": "无法提取账户安全链接"})
				continueExecute = false
			} else {
				d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "进入账户安全设置"})
				resp, document, err = amz.Navigate(link)
			}
		case responsePath == "/ap/profile/mobilephone":
			d.sendLog(map[string]string{"status": "success", "email": registerUser.Email, "content": "删除电话号码"})
			resp, document, err = amz.DeleteMobile(document)
			if err != nil {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
			} else {
				cookies, _ := amz.GetCookies()
				global.BM_API.FeedbackRegisterAccount(registerUser.Name, registerUser.Email, registerUser.Password, cookies)
			}

			continueExecute = false
		case responsePath == `/ap/register`:
			if strings.Contains(responseUrl, "arb=") {
				d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "邮箱存在，强制注册"})
				resp, document, err = amz.ForceEmailRegister(document)
				if err != nil {
					d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
					continueExecute = false
				}
			} else {
				d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "开始注册"})
				resp, document, err = amz.Register(registerUser.Name, registerUser.Email, registerUser.Password, document)
				ioutil.WriteFile("register.html", resp.Body(), 0644)
				time.Sleep(1 * time.Second)
				if err != nil {
					d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
					continueExecute = false
				}
			}

		case amz.IsSwitchAccount(document):
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "切换登陆账号"})
			resp, document, err = amz.SwitchAccount(document)
			if err != nil {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
				continueExecute = false
			}
		case responsePath == "/ap/signin": //登录
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "开始登录"})
			resp, document, err = amz.Login(registerUser.Email, registerUser.Password, document)
			if err != nil {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
				continueExecute = false
			}
		case responsePath == "/ap/register/ref=ap_register_mase_warn_claim_pop":
			ioutil.WriteFile("email_force.html", resp.Body(), 0644)
			continueExecute = false
		//case amz.IsCaptchaPage(document):
		case amz.IsFunCaptcha(document):
			var req api2captcha.Request
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "验证码类型为Func"})
			cap := api2captcha.FunCaptcha{
				SiteKey:   "2F1CD804-FE45-F12B-9723-240962EBA6F8",
				Url:       resp.RawResponse.Request.URL.String(),
				Surl:      "https://client-api.arkoselabs.com",
				UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
			}
			req = cap.ToRequest()
			req.SetProxy("HTTP", fmt.Sprintf("%s:%s@tunnel5.qg.net:14295", global.BM_CONFIG.Section("proxy").Key("username").Value(), global.BM_CONFIG.Section("proxy").Key("password").Value()))
			//req.SetProxy("HTTP", "185.228.219.137:8800")
			//req.SetProxy("HTTP", "lum-customer-c_17e58ad2-zone-residential-country-ad:Jjyylu102697@zproxy.lum-superproxy.io:22225")
			//req.Params["debug_dump"] = "1"
			//req.SetProxy("HTTP", "lum-customer-c_17e58ad2-zone-residential:Jjyylu102697@47.90.188.193:24001")
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "等待验证码结果"})

			code, err := global.BM_2CAPTCHA.Solve(req)
			if err != nil {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
				continueExecute = false
			} else {
				d.sendLog(map[string]string{"status": "success", "email": registerUser.Email, "content": fmt.Sprintf("接收到结果: %s", code)})
				resp, document, err = amz.SubmitFunCaptchaVerify(document, code)
				if err != nil {
					d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
					continueExecute = false
				}
			}
		case amz.IsNormalCaptcha(document):
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "验证码类型为Normal"})
			captchaUrl, err := amz.ExtractCaptchaImage(document)
			if err != nil {
				continueExecute = false
			}

			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "下载验证码图片"})
			captchaResp, err := http.Get(captchaUrl)
			if err != nil {
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": "无法下载验证码图片"})
				continueExecute = false
			} else {
				d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "图片解码"})
				imgCoupon, err := gif.DecodeAll(captchaResp.Body)
				if err != nil {
					d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": "无法decode图片"})
					continueExecute = false
				} else {
					imgCoupon.LoopCount = 0
					// EncodeAll to the buffer
					var buff bytes.Buffer
					err = gif.EncodeAll(&buff, imgCoupon)

					if err != nil {
						d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": "无法encode图片"})
						continueExecute = false
						continue
					} else {
						d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "压缩验证码"})
						img := global.BM_API.ConvertGif(base64.StdEncoding.EncodeToString(buff.Bytes()))
						cap := api2captcha.Normal{
							//File: "http://121.40.28.56/topamazon/_gif/small_7099227aae94427ab80a4f525cb8ec5f.gif",
							//File: "./small_7099227aae94427ab80a4f525cb8ec5f.gif",
							//Base64: base64.StdEncoding.EncodeToString(buff.Bytes()),
							Base64: img,
						}

						req := cap.ToRequest()
						req.Params["method"] = "base64"
						req.Params["min_len"] = strconv.FormatInt(int64(6), 10)
						req.Params["max_len"] = strconv.FormatInt(int64(6), 10)
						d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "等待Normal结果"})

						code, err := global.BM_2CAPTCHA.Solve(req)
						if err != nil {
							d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
							continueExecute = false
						} else {
							d.sendLog(map[string]string{"status": "success", "email": registerUser.Email, "content": fmt.Sprintf("接收到结果: %s", code)})

							resp, document, err = amz.SubmitNormalCaptchaVerify(document, code)

							if err != nil {
								d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
								continueExecute = false
							}
						}
					}
				}
			}

		case amz.IsEmailOptPage(document):
			resendTime := 1
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "获取邮件验证码"})

			ticker := time.NewTicker(5 * time.Second)
			for {
				<-ticker.C

				code := global.BM_API.GetEmailOTP(registerUser.Email)
				if code != "" {
					d.sendLog(map[string]string{"status": "success", "email": registerUser.Email, "content": fmt.Sprintf("邮件验证码结果为: %s", code)})
					d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "提交邮件验证"})
					resp, document, err = amz.SubmitEmailOTP(document, code)
					for _, cookie := range resp.Cookies() {
						d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": fmt.Sprintf("%s", cookie.Name)})
					}
					if err != nil {
						d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": fmt.Sprintf("提交email Opt出错: %s", err.Error())})
					}

					ticker.Stop()
					break
				} else {
					if resendTime%10 == 0 {
						d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "重发邮件验证码"})
						_, _, err = amz.SubmitResendEmailOTP(document)
					} else {
						d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "等待5秒获取邮件验证码"})
					}
				}

				resendTime++
			}

			//for {
			//	code := global.BM_API.GetEmailOTP(registerUser.Email)
			//	if code != "" {
			//		d.sendLog(map[string]string{"status": "success", "email": registerUser.Email, "content": fmt.Sprintf("邮件验证码结果为: %s", code)})
			//		d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "提交邮件验证"})
			//		resp, document, err = amz.SubmitEmailOTP(document, code)
			//		for _, cookie := range resp.Cookies() {
			//			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": fmt.Sprintf("%s", cookie.Name)})
			//		}
			//		if err != nil {
			//			d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": fmt.Sprintf("提交email Opt出错: %s", err.Error())})
			//		}
			//		break
			//	} else {
			//		if resendTime%10 == 0 {
			//			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "重发邮件验证码"})
			//			_, _, err = amz.SubmitResendEmailOTP(document)
			//		} else {
			//			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "等待5秒获取邮件验证码"})
			//		}
			//		resendTime++
			//		time.Sleep(5 * time.Second)
			//	}
			//}
		case amz.IsMobilePage(document) && responsePath != "/ap/profile/mobilephone":
			ioutil.WriteFile("mobile.html", resp.Body(), 0644)
			err = amz.CheckPhone(document)
			if err != nil {
				ioutil.WriteFile("mobile_exists.html", resp.Body(), 0644)
				d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
				continueExecute = false
			} else {
				d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "获取手机号"})
				//id, countryCode, phoneNumber, err := global.BM_PHONEPROVIDER.GetNumber(map[string]interface{}{"country": "russia", "operator": "mts", "name": "amazon", "forwardingNumber": ""})
				phoneDetail.ID, phoneDetail.CountryCode, phoneDetail.PhoneNumber, err = global.BM_PHONEPROVIDER.GetNumber(map[string]interface{}{"channel": "2", "country": "IN", "pid": "31"})
				//phoneDetail.ID, phoneDetail.CountryCode, phoneDetail.PhoneNumber, err = 0, "cn", "13454496066", nil
				if err != nil {
					d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": err.Error()})
					continueExecute = false
				}

				//numberDetail, _ := global.BM_5SIM.GetNumber("russia", "mts", "amazon", "")
				//numberDetail, _ := global.BM_SUPERSMS.GetNumber("2", "IN", "31")
				//numberDetail, _ := global.BM_SMSMAN.GetNumber(10, 176)
				if phoneDetail.PhoneNumber != "" {
					d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": fmt.Sprintf("国家: %s, 手机号为: %s", phoneDetail.CountryCode, phoneDetail.PhoneNumber)})
					d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "提交手机号"})
					resp, document, err = amz.SubmitPhone(document, phoneDetail.CountryCode, phoneDetail.PhoneNumber)
				} else {
					d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": "没有电话号码可领取"})
					continueExecute = false
				}
			}

			//for {
			//	code := global.(email)
			//	if code != "" {
			//		resp, document, err = amz.SubmitEmailOTP(document, code)
			//		break
			//	} else {
			//		time.Sleep(3 * time.Second)
			//	}
			//}
		case amz.IsMobileOptPage(document):
			resendTime := 1

			ticker := time.NewTicker(5 * time.Second)
			for {
				<-ticker.C

				//readCode, _ := ioutil.ReadFile("sms.txt")
				//code := string(readCode)
				code, _ := global.BM_PHONEPROVIDER.GetSms(phoneDetail.ID)
				//codeDetail, _ := global.BM_5SIM.GetCode(phoneTaskId)
				//codeDetail, _ := global.BM_SUPERSMS.GetCode(phoneTaskId)
				//codeDetail, _ := global.BM_SMSMAN.GetCode(phoneTaskId)
				if code != "" {
					d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": fmt.Sprintf("提交手机验证码 -> %s", code)})
					resp, document, err = amz.SubmitMobileOTP(document, code)
					//resp, document, err = amz.Navigate(`/ap/cnep?openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fyour-account&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0`)
					ticker.Stop()
					break
				} else {
					if resendTime%21 == 0 {
						d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "修改电话号码"})
						//global.BM_5SIM.CancelOrder(phoneTaskId)
						_ = global.BM_PHONEPROVIDER.ReleaseNumber(phoneDetail.PhoneNumber)
						resp, document, err = amz.ChangeMobile(document)
						ticker.Stop()
						break
					} else {
						if resendTime%11 == 0 {
							d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "重发验证码"})
							_, _, err = amz.SubmitResendMobileOTP(document)

							//time.Sleep(3 * time.Second)
						} else {
							d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "等待手机验证码..."})
							//time.Sleep(5 * time.Second)
						}

						resendTime++
					}
				}

			}

			//for {
			//	codeDetail, _ := global.BM_5SIM.GetCode(phoneTaskId)
			//	//codeDetail, _ := global.BM_SUPERSMS.GetCode(phoneTaskId)
			//	//codeDetail, _ := global.BM_SMSMAN.GetCode(phoneTaskId)
			//	if codeDetail.Code != "" {
			//		d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": fmt.Sprintf("提交手机验证码 -> %s", codeDetail.Code)})
			//		resp, document, err = amz.SubmitMobileOTP(document, codeDetail.Code)
			//		//resp, document, err = amz.Navigate(`/ap/cnep?openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fyour-account&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0`)
			//		break
			//	} else {
			//		if resendTime > 20 {
			//			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "修改电话号码"})
			//			resp, document, err = amz.ChangeMobile(document)
			//			break
			//		} else {
			//			if resendTime%10 == 0 {
			//				d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "重发验证码"})
			//				_, _, err = amz.SubmitResendMobileOTP(document)
			//				time.Sleep(3 * time.Second)
			//			} else {
			//				d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": fmt.Sprintf("等待手机验证码, 订单号:%d", phoneTaskId)})
			//				time.Sleep(5 * time.Second)
			//			}
			//		}
			//
			//		resendTime++
			//	}
			//}
		case responsePath == "/ap/cnep":
			resp, document, err = amz.UnbindMobile(document)
		case responsePath == "/ap/mobileclaimconflict":
			ioutil.WriteFile("mobileclaimconflict.html", resp.Body(), 0644)
			d.sendLog(map[string]string{"status": "info", "email": registerUser.Email, "content": "手机号已经存在了,强制注册"})
			resp, document, err = amz.ForceRegister(document)
		default:
			d.sendLog(map[string]string{"status": "error", "email": registerUser.Email, "content": fmt.Sprintf("未知内容, 退出, 当前页面: %s", responseUrl)})
			ioutil.WriteFile("unknown.html", resp.Body(), 0644)
			continueExecute = false
		}

		if resp != nil {
			responsePath = resp.RawResponse.Request.URL.Path
			responseUrl = resp.RawResponse.Request.URL.String()
		}
	}

	global.BM_EVENTBUS.Publish("register:deleteData", registerUser.Email)

	var statistic map[string]string
	//total := utils.ArrayCountValues(accountStatistic[registerUser.Email]["success"].([]interface{}))
	//global.BM_EVENTBUS.Publish("deals:feedback", total)
	//
	//statisticFormat := fmt.Sprintf("\n 邮箱    : %s\t\n 邮编    : %s\n 收货地址: %s\n 信用卡号: %s\n asins:   %s\n 订单总数: %d\n 订单列表: %s\n===========================================",
	//	registerUser.Email,
	//	accountStatistic[registerUser.Email]["zipCode"],
	//	accountStatistic[registerUser.Email]["address"],
	//	accountStatistic[registerUser.Email]["cc"],
	//	strings.Join(utils.RemoveDuplicateStr(accountStatistic[registerUser.Email]["asins"].([]string)), "\t"),
	//	len(accountStatistic[registerUser.Email]["orders"].([]string)),
	//	strings.Join(accountStatistic[registerUser.Email]["orders"].([]string), "\t"),
	//)
	//
	//statistic = map[string]string{"status": "info", "content": statisticFormat}

	return statistic
}
